import random
mylist = [random.randint(0,100) for i in range(10)]
print(mylist)
mylist2 = [i*i for i in mylist]
print(mylist2)
mylist3 = [i for i in mylist if i%2==0]
print(mylist3)
mymatrix=[[1,3,5,8],[4,2,6,7],[9,0,4,2]]
print("按行遍历矩阵")
print([row for row in mymatrix])
print("按列遍历矩阵")
print([mymatrix[i][1]for i in range(3)])
print("遍历矩阵中的每一个元素")
print([mymatrix[row][col] for row in range(3) for col in range (4)])
print("使用列表解析进行矩阵转置")
transposed = [list(row) for row in zip(*mymatrix)]
print([transposed])